<?php

/**
 * This is the model class for table "m_projects".
 *
 * The followings are the available columns in table 'm_projects':
 * @property integer $id
 * @property string $name
 * @property string $description
 * @property string $process_status
 * @property integer $status
 * @property string $special
 * @property string $budgetmin
 * @property string $budgetmax
 * @property integer $currency
 * @property string $expires
 * @property string $creator
 * @property string $attachment
 * @property integer $skillid
 * @property integer $pcat1
 * @property integer $pcat2
 * @property integer $pcat3
 * @property integer $creatorid
 * @property string $regdate
 * @property string $update_date
 */
class Project extends BaseModel
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Project the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'm_projects';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id, name, description, process_status, status, special, budgetmin, budgetmax, currency, expires, creator, attachment, pcat1, pcat2, pcat3', 'required'),
			array('id, status, currency, skillid, pcat1, pcat2, pcat3, creatorid', 'numerical', 'integerOnly'=>true),
			array('name, process_status, budgetmin, budgetmax, creator, attachment', 'length', 'max'=>250),
			array('special', 'length', 'max'=>8),
			array('regdate, update_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, name, description, process_status, status, special, budgetmin, budgetmax, currency, expires, creator, attachment, skillid, pcat1, pcat2, pcat3, creatorid, regdate, update_date', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'name' => 'Name',
			'description' => 'Description',
			'process_status' => 'Process Status',
			'status' => 'Status',
			'special' => 'Special',
			'budgetmin' => 'Budgetmin',
			'budgetmax' => 'Budgetmax',
			'currency' => 'Currency',
			'expires' => 'Expires',
			'creator' => 'Creator',
			'attachment' => 'Attachment',
			'skillid' => 'Skillid',
			'pcat1' => 'Pcat1',
			'pcat2' => 'Pcat2',
			'pcat3' => 'Pcat3',
			'creatorid' => 'Creatorid',
			'regdate' => 'Regdate',
			'update_date' => 'Update Date',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('process_status',$this->process_status,true);
		$criteria->compare('status',$this->status);
		$criteria->compare('special',$this->special,true);
		$criteria->compare('budgetmin',$this->budgetmin,true);
		$criteria->compare('budgetmax',$this->budgetmax,true);
		$criteria->compare('currency',$this->currency);
		$criteria->compare('expires',$this->expires,true);
		$criteria->compare('creator',$this->creator,true);
		$criteria->compare('attachment',$this->attachment,true);
		$criteria->compare('skillid',$this->skillid);
		$criteria->compare('pcat1',$this->pcat1);
		$criteria->compare('pcat2',$this->pcat2);
		$criteria->compare('pcat3',$this->pcat3);
		$criteria->compare('creatorid',$this->creatorid);
		$criteria->compare('regdate',$this->regdate,true);
		$criteria->compare('update_date',$this->update_date,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}